package com.itcoon.cloud.framework.webmvc.exception.handler;

import com.itcoon.cloud.framework.webmvc.response.ApiResponse;
import com.itcoon.cloud.framework.webmvc.utils.ApiResponseUtils;
import org.springframework.http.HttpStatus;

import javax.servlet.http.HttpServletResponse;

public class DefaultExceptionHandler implements GlobalExceptionHandler<Exception> {

    @Override
    public boolean support(Exception e) {
        return true;
    }

    @Override
    public void handle(HttpServletResponse response, Exception e) {
        loopLog(e);
        ApiResponseUtils.writeJsonResponse(response, ApiResponse.error(), HttpStatus.INTERNAL_SERVER_ERROR.value());
    }
}
